package com.ytf.core.web.service.impl;

import com.ytf.core.web.pojo.model.Permission;
import com.ytf.core.web.mapper.PermissionMapper;
import com.ytf.core.web.service.IPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author YTF
 * @since 2025-05-20
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {

    @Override
    public Boolean existsById(Long id) {
        return lambdaQuery().eq(Permission::getId, id).exists();
    }

    @Override
    public Boolean existsByIds(List<Long> permissionIds) {
        Long count = lambdaQuery().in(Permission::getId, permissionIds).count();
        return count == permissionIds.size();
    }

    @Override
    public Boolean existsByPermKeyAndIdNot(String permKey, Long id) {
        return lambdaQuery().eq(Permission::getPermKey,permKey)
                .ne(Permission::getId,id).exists();
    }
}
